﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.MODEL.FoundationModel;

namespace MINERP.OverOrder.Forms
{
    

    public partial class UOutShopInfo : UserControl
    {
        public UOutShopInfo()
        {
            InitializeComponent();
        }
        public string ShopName { set; get; }
        public string ShopCode { get; set; }
        public int ShopId{ get; set;}
        public int Num { set; get; }
        

        

        public delegate void DoSelectShop(int intShopId);//选中厂商
        public delegate void DoDrag(List<string> strList);//执行拖拽的具体动作
        public delegate void DoStyle();
        public event DoSelectShop GetSelectedShopId;
        public event DoDrag ExecuteDrag;
        public event DoSelectShop SetSelectedShop;
        public event DoStyle ClearStyle;
        public void DisplayInfo()
        {
            this.label_ShopName.Text = this.ShopName;
            label_Code.Text = "厂商代码:" + this.ShopCode;
            label_name.Text = "厂商名称:"+this.ShopName;
            
        }

       

        private void UOutShopInfo_DragEnter(object sender, DragEventArgs e)
        {
            

            if (e.Data.GetDataPresent(typeof(List<string>)))
            {
                List<string> obj = (List<string>)e.Data.GetData(typeof(List<string>));
                if (obj.Count>0)
                {
                    e.Effect = DragDropEffects.Copy;
                    //GetSelectedShopId(this.ShopId);
                    ClearStyle();
                    this.BackColor = Color.LightGreen;
                    this.BorderStyle = BorderStyle.Fixed3D;
                }

            }
        }

    
        private void UOutShopInfo_Click(object sender, EventArgs e)
        {
            SetSelectedShop(this.ShopId);

            this.BorderStyle = BorderStyle.Fixed3D;
            this.BackColor = Color.LightGreen;

        }

        private void UOutShopInfo_DragDrop(object sender, DragEventArgs e)
        {
            
            if (e.Data.GetDataPresent(typeof(List<string>)))
            {
                GetSelectedShopId(this.ShopId);
                e.Effect = DragDropEffects.All;
                this.BorderStyle = BorderStyle.Fixed3D;
                this.BackColor = Color.LightGreen;
                ExecuteDrag((List<string>)(e.Data.GetData(typeof(List<string>))));

            }

        }

        private void UOutShopInfo_DragLeave(object sender, EventArgs e)
        {
            this.BorderStyle = BorderStyle.FixedSingle;
            this.BackColor = Color.White;
        }


        public void SetEvent(Control control)
        {
            control.Click += new EventHandler(UOutShopInfo_Click);
            //control.DoubleClick += new EventHandler(UTaskList_DoubleClick);
            ControlCollection ccl = control.Controls;
            foreach (Control collection in ccl)
            {
                SetEvent(collection);
            }

        }

        private void UOutShopInfo_Load(object sender, EventArgs e)
        {
            SetEvent(splitContainer1);
        }

        
    }
}
